package com.dxy.hms.service.impl;

import com.dxy.hms.model.entity.Config;
import com.dxy.hms.mapper.ConfigMapper;
import com.dxy.hms.service.ConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

/**
* <p>
* 配置表 服务实现类
* </p>
*
* @author dxy
* @since 2024-10-07
*/
@Slf4j
@Service
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements ConfigService {

    @Override
    public void add(Config entity) {
        baseMapper.insert(entity);
    }

    @Override
    public void updById(Config entity) {
        baseMapper.updateById(entity);
    }

    @Override
    public void delByIds(List<Long> ids) {
        baseMapper.deleteBatchIds(ids);
    }

    @Override
    public Config getDetail(Long id) {
        return baseMapper.selectById(id);
    }

    @Override
    public IPage<Config> getPage(Long pageNum, Long pageSize) {
        if (pageNum == null || pageNum <= 0) { pageNum = 1L; }
        if (pageSize == null || pageSize <= 0) { pageSize = 10L; }
        IPage<Config> page = new Page<>(pageNum, pageSize);
        Wrapper<Config> wrapper = new LambdaQueryWrapper<Config>();
        return baseMapper.selectPage(page, wrapper);
    }

}
